import logging

import pytest

from resource.pom.system_ui import SystemUI


class Test:
    system_ui = SystemUI

    @pytest.mark.parametrize('setup_teardown', [None], indirect=True)
    def test(self, setup_teardown, device):
        logging.info('步骤1：右上角下划，呼出控制中心')
        wifi_status0 = device.get_wifi_status()
        device.dropdown_controller_center()
        logging.info('预期结果1：成功进入控制中心')
        device.wait(1)
        device.refresh_layout()
        device.assert_text_exist('控制中心')
        logging.info('步骤2.点击控制中心WLAN按钮')
        wlan = device.get_element_by_text('WLAN')
        x, y = device.center_of_element(wlan)
        device.click(x - 100, y)
        device.wait(5)
        logging.info('预期结果2.点击WLAN有效，与设置WiFi开关同步变化')
        wifi_status1 = device.get_wifi_status()
        assert wifi_status0.get('active') != wifi_status1.get('active'), 'wlan打开或关闭失败'
